// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   CubicLineChart.java

package org.achartengine.chart;

import android.graphics.*;
import org.achartengine.model.Point;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;

// Referenced classes of package org.achartengine.chart:
//			LineChart

public class CubicLineChart extends LineChart
{

	public static final String TYPE = "Cubic";
	private float firstMultiplier;
	private float secondMultiplier;
	private Point p1;
	private Point p2;
	private Point p3;

	public CubicLineChart()
	{
		p1 = new Point();
		p2 = new Point();
		p3 = new Point();
		firstMultiplier = 0.33F;
		secondMultiplier = 1.0F - firstMultiplier;
	}

	public CubicLineChart(XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, float f)
	{
		super(xymultipleseriesdataset, xymultipleseriesrenderer);
		p1 = new Point();
		p2 = new Point();
		p3 = new Point();
		firstMultiplier = f;
		secondMultiplier = 1.0F - firstMultiplier;
	}

	protected void drawPath(Canvas canvas, float af[], Paint paint, boolean flag)
	{
		Path path = new Path();
		float f = af[0];
		float f1 = af[1];
		path.moveTo(f, f1);
		for (int i = 0; i < af.length; i += 2)
		{
			int j = i + 2 >= af.length ? i : i + 2;
			int k = i + 4 >= af.length ? j : i + 4;
			calc(af, p1, i, j, secondMultiplier);
			p2.setX(af[j]);
			p2.setY(af[j + 1]);
			calc(af, p3, j, k, firstMultiplier);
			path.cubicTo(p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY());
		}

		canvas.drawPath(path, paint);
	}

	private void calc(float af[], Point point, int i, int j, float f)
	{
		float f1 = af[i];
		float f2 = af[i + 1];
		float f3 = af[j];
		float f4 = af[j + 1];
		float f5 = f3 - f1;
		float f6 = f4 - f2;
		point.setX(f1 + f5 * f);
		point.setY(f2 + f6 * f);
	}

	public String getChartType()
	{
		return "Cubic";
	}
}
